import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
//导入注册页面组件
import MerchantLogin from '@/views/MerchantLogin'
//导入注册页面组件
import MerchantRegister from '@/views/MerchantRegister'
//导入添加商品组件
import Agoods from "@/views/Agoods"
//导入商品详情页面
import GoodsDetail from "@/views/GoodsDetail"
//导入左侧框架
import Left from '@/views/Left'
//导入商家登录后的首页
import Welcome from '@/views/Welcome'
//导入商家的商品列表
import Goods from '@/views/Goods'
//导入商家的订单列表
import Order from '@/views/Order'
//商家修改用户订单地址
import ChangeAddress from '@/views/ChangeAddress'
//商家修改用户订单状态
import ChangeState from '@/views/ChangeState'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/HelloWorld',
      name: 'HelloWorld',
      component: HelloWorld,
      meta: {
        requireAuth: false
      }
    },
    //导入商家的订单列表路由
    {
      name:'order',
      path:'/order',
      component:Order,
      meta: {
        requireAuth: false
      }
    },
    //商家修改用户订单地址路由
    {
      name:'address',
      path:'/changeAddress',
      component:ChangeAddress,
      meta: {
        requireAuth: false
      }
    },
    //商家修改用户订单状态路由
    {
      name:'state',
      path:'/changeState',
      component:ChangeState,
      meta: {
        requireAuth: false
      }
    },
    //添加商家登录页面路由
    {
      path:'/',
      name: 'MerchantLogin',
      component:MerchantLogin,
      meta: {
        requireAuth: false
      }
    },
    //添加商家注册页面路由
    {
      path:'/MerchantRegister',
      name: 'MerchantRegister',
      component:MerchantRegister,
      meta: {
        requireAuth: false
      }
    },
    //添加商品新增路由
    {
      path: '/Agoods',
      name: 'Agoods',
      component:Agoods,
      meta: {
        requireAuth: false
      }
    },
    //添加商品详情路由
    {
      path:'/GoodsDetail',
      name:'/GoodsDetail',
      component:GoodsDetail,
      meta:{
        requireAuth: false
      }
    },
    //添加商品列表路由
    {
      path: '/Goods',
      name:'Goods',
      component:Goods,
      meta:{
        requireAuth: false
      }
    },
    //左侧框架栏
    {
      path:'/Left',
      name:'Left',
      component:Left,
      meta:{
        requireAuth: false
      },
    },
    //欢迎页
    {
      path:'/Welcome',
      name:'Welcome',
      component:Welcome,
      meta:{
        requireAuth: false
      },
    },
  ],
})

//解决VUE路由跳转出现Redirected when going from "/xxx" to "/yyy" via a navigation guard.报错
/*Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}*/
